//
//  WeatherCollectionViewController.m
//  weather
//
//  Created by 大L君的无敌战舰 on 16/4/12.
//  Copyright © 2016年 bigL.com. All rights reserved.
//

#import "WeatherCollectionViewController.h"
#import "WeatherMainCell.h"

@interface WeatherCollectionViewController ()

@end

@implementation WeatherCollectionViewController

static NSString * ID = @"weather";

/**
 *  初始化
 */
- (instancetype)init {
    //1.UICollectionView创建时必须得要指定布局方式
    UICollectionViewFlowLayout *flowL = [[UICollectionViewFlowLayout alloc] init];
    //设置每一个格子的大小
    flowL.itemSize = BLScreenSize;
    //设置最小的行间距
    flowL.minimumLineSpacing = 0;
    //设置每个格子之间的距离
    flowL.minimumInteritemSpacing = 0;
    //设置滚动的方向
    flowL.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    return [super initWithCollectionViewLayout:flowL];
}


- (void)viewDidLoad
{
    //解决bug
    self.automaticallyAdjustsScrollViewInsets = NO;
    //设置背景
    [self setBackgroundForTableView:@"bg_night_sunny"];
    
    [self.collectionView registerClass:[WeatherMainCell class] forCellWithReuseIdentifier:ID];
}

/**
 *  设置背景图片
 */
- (void)setBackgroundForTableView:(NSString *)backGroundImage
{
    UIImage * image = [UIImage imageIncertitudeImageName:backGroundImage];
    self.collectionView.layer.contents = (id)image.CGImage;
}


#pragma mark <UICollectionViewDataSource>

//总共有多组
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return 1;
}


//每一组有多个个格子(item)
- (NSInteger)collectionView:(UICollectionView *)collectionView
     numberOfItemsInSection:(NSInteger)section {
    
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                  cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    //2.UICollectionViewCell必须得要通过注册的方式进行创建
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];

    return cell;
}



@end
